<template>
  <render :data="content"></render>
</template>

<script>
export default {
  name: "ExAsyncRender"
}
</script>
<script setup>
import ajax from '@/utils/ajax'
import {ref, useAttrs} from 'vue'
import {useInjectRenderContext} from "@/components/render/context";
const props = defineProps({
  url:String,
  params:{
    type:Object,
    default:{}
  }
})
const attrs = useAttrs()
const content = ref()
requestData()
function requestData(){
  let context = useInjectRenderContext()
  if(attrs.scopeProp && attrs.scopeProp.row){
    context = attrs.scopeProp.row
  }
  content.value = null
  ajax({
    url:props.url,
    data:props.params,
    method:'post'
  },false,[],null,context).then(res=>{
    content.value = res
  })
}
defineExpose({
  requestData
})
</script>
<style scoped>

</style>
